package com.broadengate.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.broadengate.dao.TransferDao;
import com.broadengate.model.Card;
import com.broadengate.model.Deposit;
import com.broadengate.model.Transfer;

/******
 * 提供转账时与数据库的交互方法
 * 方法主要有trans()实现转账；deleteTrans()删除转账记录
 */
public class TransferDaoImpl extends HibernateDaoSupport implements TransferDao {
	@SuppressWarnings("unchecked")
	public void trans(Card cardDestined,Card cardSource,Transfer transfer){
		
		getHibernateTemplate().update(cardDestined);
		getHibernateTemplate().update(cardSource);
		getHibernateTemplate().save(transfer);
	}
	
	public void deleteTrans(String cardNO){
		List<Transfer> list = new ArrayList<Transfer>();
		list= getHibernateTemplate().find("from Transfer transfer where transfer.cardBySourceCardId.cardNo='"+cardNO+"'");	
		list.clear();

	}
}
